package com.liangzhong.model.club.vo
{
	import com.common.stdlib.DateUtil;
	import com.global.GlobalDef;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.buffer.vo.BufferVo;

	/**
	 * buff 信息
	 * @author nick
	 */	
	public class BuffVo
	{
		/**
		 *buffid 
		 */
		public var buffid		:int;
		/**
		 *开始时间 
		 */
		public var time			:int;
		/**
		 * 持续时间
		 */
		public var contime		:int;
		/**
		 *解析 
		 * @param $obj
		 */		
		public function analysis($obj:Object):void
		{
			for (var str:String in $obj)
			{
				if(this.hasOwnProperty(str))
				{
					this[str] = $obj[str];
				}
			}
		}
		/**
		 *图标地址 
		 * @return 
		 * 
		 */		
		public function get url():String 
		{
			return GlobalDef.Web_Res_Url + "buff/" + buffid + ".png";
		}
		/**
		 * 是否过期 
		 * @return true -- out
		 * 
		 */		
		public function isOutTime():Boolean
		{
			var endDateTimes :Number = (time + contime);
			if(buffid > 0 && (time == 0 || contime == 0))
			{
				return false;
			}
			if(AppData.getInstance().time > endDateTimes)
			{
				return true;
			}
			return false;
		}
		/**
		 *获取显示的tips 
		 * @return 
		 * 
		 */		
		public function get bufferTips():String
		{
			var info :String = "";
			var bufferVo :BufferVo = AppData.getInstance().bufferManager.getBufferById(buffid);
			if(bufferVo)
			{
				info += "<p align='left'>" + bufferVo.bname + "\n</p>";
				info += bufferVo.bufferTips;
			}
			var endDate :Date = new Date((time + contime)*1000);
			if(buffid > 0 && (time == 0 || contime == 0))
			{
				info += "<p align='left'>有效期:永久" + "</p>";
			}
			else
			{
				info += "<p align='left'>有效期:" + DateUtil.objToShowTimeFormat(endDate) + "</p>";;
			}
			return info;
		}
	}
}